package controllers

import (
	"github.com/astaxie/beego"
)

type TestInputController struct {
	beego.Controller
}

type User struct {
	Username string
	Password string

}

func (c *TestInputController) Get() {
	//获取get请求中的id
	//id := c.GetString("id")
	//c.Ctx.WriteString(id)

	//比较原始的写法。
	//name := c.Input().Get("name")
	//c.Ctx.WriteString("<br />" + name)

	c.Ctx.WriteString(`<html><form action="/test_input" method="post"> 
				<input type="text" name="Username" />
				<input type="password" name="Password" />
				<input type="submit" value="提交" />
			</form> </html>`)
}


func (c *TestInputController) Post() {
	u := User{}
	if err := c.ParseForm(&u) ; err != nil{

	}

	c.Ctx.WriteString("Username:" + u.Username + u.Password)
	//id := this.Input().Get("id")
	//intid, err := strconv.Atoi(id)
}

